/***************************************************************************
 * *   File name: ClientManager.h
 * *    Describe: 实现客户端的管理
 * *  Created on: 2016-8-6
 * *      Author: dengxiudong
 * ************************************************************************/ 
#ifndef _CLIENT_MANAGER_H_
#define _CLIENT_MANAGER_H_


#include "Client.h"

#include <memory>
#include <unordered_map>
#include <mutex>


class ClientManager
{
private:
	ClientManager() {}
	virtual ~ClientManager() {}
public:
	static ClientManager *instance();

	Client *getClient(uint32_t clientId);
	void addClient(uint32_t clientId, Client *ptrCli);
	bool delClient(uint32_t clientId, Client * ptrCli);
	bool isExist(uint32_t clientId);
private:
	std::unordered_map<uint32_t, Client*> m_cliMap;
	std::mutex m_mutex;
};

#endif


